import os

# 1 处理初始文件
folder = "D:\Engineer_workshop\SW station\work\JDEC\project data\percent-28"
picture_type = "28_"
for i, filename in enumerate(os.listdir(folder)):
    timestaps = filename[6:]
    timestaps = timestaps[:-7]
    new_name = f"{picture_type + timestaps}.bmp"
    os.rename(os.path.join(folder, filename), os.path.join(folder, new_name))
    print(i, filename, new_name)

folder = "D:\Engineer_workshop\SW station\work\JDEC\project data\percent-36"
picture_type = "36_"
for i, filename in enumerate(os.listdir(folder)):
    timestaps = filename[6:]
    timestaps = timestaps[:-7]
    new_name = f"{picture_type + timestaps}.bmp"
    os.rename(os.path.join(folder, filename), os.path.join(folder, new_name))
    print(i, filename, new_name)

# 2 调整现有文件
# folder_train = "C:\Temp\TF2.4 training\splited dataset\\train"
# folder_test = "C:\Temp\TF2.4 training\splited dataset\\test"
#
# def remane_files_in_folder(folder_path):
#     for i, filename in enumerate(os.listdir(folder_path)):
#         # filename_head = filename[:3]
#         # filename_head = filename_head[:2]
#         # filename_tail = filename[3:]
#         # new_name = f"{filename_head + filename_tail}.bmp"
#         new_name = filename[:-4]
#         os.rename(os.path.join(folder_path, filename), os.path.join(folder_path, new_name))
#         print(i, filename, new_name)
#
# remane_files_in_folder(folder_train)
# remane_files_in_folder(folder_test)
